package com.arrays.a4_digui;

/**
 * 递归
 */
public class Recursion {
    /*
    2的幂
     */
    public boolean isPowerOfTwo(int n) {
      if(n<1){
          return false;
      }
      if (n%2!=0){
          return false;
      }
      if (n==1||n==2){
          return true;
      }
      return isPowerOfTwo(n/2);

    }

    public static void main(String[] args) {
        int n=18;
        Recursion re = new Recursion();
        boolean res = re.isPowerOfTwo(n);
        System.out.println(res);
    }
}
